package com.pj.wisdomlogistics.mvp.presenter;


import com.pj.wisdomlogistics.entity.CarPoritionInfo;
import com.pj.wisdomlogistics.mvp.contract.CarFreeContract;
import com.pj.wisdomlogistics.mvp.frame.ActivityPresenter;
import com.pj.wisdomlogistics.mvp.model.CarFreeModel;
import com.pj.wisdomlogistics.rx.FilterSubscriber;


public class CarFreePresenter extends ActivityPresenter<CarFreeModel, CarFreeContract.View> implements CarFreeContract.Presenter {

    @Override
    public void findCarAndDriver() {
        addSubscription(getModel().submitCarApply(), new FilterSubscriber<CarPoritionInfo>() {
            @Override
            public void onNext(CarPoritionInfo mInfo) {
                getView().onSuccess(mInfo);
            }

            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorMsg);
            }


        });
    }

    @Override
    public void updateCarState(int carID , int state) {
        addSubscription(getModel().updateCarState(carID , state), new FilterSubscriber() {
            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorMsg);
            }

            @Override
            public void onNext(Object mO) {
                getView().onSendSuccess();
            }
        });
    }


}
